#include "settingsmanager.h"
#include "constants.h"

#include <QVariant>
#include <QSettings>

SettingsManager::SettingsManager()
{
    settings = new QSettings(APP_ORGANIZATION, APP_NAME);
}

SettingsManager::~SettingsManager()
{
    delete settings;
}

void SettingsManager::saveSettings(const QMap<SettingsKey, QVariant> &settingsMap)
{
    settings->setValue("UserID", settingsMap.value(UserID).toString());
    settings->setValue("Password", settingsMap.value(Password).toString());
    settings->setValue("Remember", settingsMap.value(Remember).toBool());
}

QMap<SettingsKey, QVariant> SettingsManager::readSettings() const
{
    QMap<SettingsKey, QVariant> settingsMap;
    settingsMap.insert(UserID, settings->value("UserID"));
    settingsMap.insert(Password, settings->value("Password"));
    settingsMap.insert(Remember, settings->value("Remember"));

    return settingsMap;
}
